//
//  XLConfig.m
//  nTZGroup
//
//  Created by William Zheng on 13-10-12.
//  Copyright (c) 2013年 hjj. All rights reserved.
//

#import "XLConfig.h"
static NSMutableDictionary *config;
@implementation XLConfig
+ (NSString *)imageDomain
{
    return [[self class] configForName:@"Domain"];
}
+ (NSString *)domain
{
    NSString *domain = [[self class] configForName:@"Domain"];
    NSString *apiPath = [[self class] configForName:@"ApiPath"];
    return [NSString stringWithFormat:@"%@%@", domain, apiPath];
}
+ (id)configForName:(NSString *)key
{
    if (!config) {
        [[self class] loadConfig];
    }
    return [config objectForKey:key];
}
+ (void)loadConfig {
    NSBundle *bundle = [NSBundle bundleForClass:[self class]];
    NSString *filePath = [bundle pathForResource:@"Config" ofType:@"plist"];
    if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
        [NSException raise:@"File not found" format:@"Couldn't find the file at path: %@", filePath];
    }
    config = [NSMutableDictionary dictionaryWithContentsOfFile:filePath];
}


@end
